<script>
	export default {
		// 全局数据，使用方式 getApp().globalData.navBarHeight
		globalData: {
			statusBarHeight: 0, // 状态栏高度(电量、信号栏)
			navBarHeight: 0, // 导航栏高度(返回按钮、微信小药丸)
			safeAreaBottom: 0, // 底部安全区域高度，主要针对iphonX以上手机
		},

		onLaunch: function() {
			// 初始化获取 导航栏高度 --- 用于多处自定义导航栏
			this.getBarHeight();
		},

		onShow: function() {},

		onHide: function() {},

		methods: {
			// 获取状态栏+导航栏高度
			getBarHeight() {
				uni.getSystemInfo({
					success: (e) => {
						let statusBarHeight = 0;
						let navBarHeight = 0;


						// #ifdef MP
						statusBarHeight = e.statusBarHeight;
						navBarHeight = 45;
						if (e.platform === 'android') {
							navBarHeight = 50;
						}
						// #endif


						// #ifdef MP-WEIXIN
						statusBarHeight = e.statusBarHeight;
						const custom = wx.getMenuButtonBoundingClientRect();
						navBarHeight = custom.height + (custom.top - e.statusBarHeight) * 2;
						// #endif


						// #ifdef MP-ALIPAY
						statusBarHeight = e.statusBarHeight;
						navBarHeight = e.titleBarHeight;
						// #endif


						// #ifdef APP-PLUS
						statusBarHeight = e.statusBarHeight;
						navBarHeight = 45;
						// #endif


						// #ifdef H5
						statusBarHeight = 0;
						navBarHeight = 45;
						// #endif

						// 全局
						this.globalData.statusBarHeight = statusBarHeight;
						this.globalData.navBarHeight = navBarHeight;
						this.globalData.safeAreaBottom = e.safeAreaInsets.bottom;
					}
				})
			},
		},
	}
</script>

<style>
	/*每个页面公共css */
	@import "/static/style/iconfont.css";
</style>
<style lang="less">
	@import "/static/less/base.less";
</style>